<template>
  <div class="layout-pd">
    <zh-card title="查询条件" v-if="pageData.showType">
      <zh-form :model="pageData.queryParams" ref="queryFormRef" label-width="160px" :span="8">
        <template v-if="pageData.advanced">
        </template>
        <zh-form-query v-model="pageData.advanced" :tableRef="queryTable" :formRef="queryFormRef"> </zh-form-query>
      </zh-form>
    </zh-card>
    <zh-table title="查询结果" ref="queryTable" size="mini" funcCode="eduStudentEnrollPreOffline0001" :columns="pageData.tableColumns" highlight-current-row>
      <template #header_button>
        <zh-button button-type="add" @click="showAdd()" v-func:eduStudentEnrollPreOffline0004>新增</zh-button>
      </template>
      <template #flag_default="{ row }">
        <zh-badge :status="statusMap[row.status].status" :text="statusMap[row.status].text" />
      </template>
      <template #operate="{ row }">
        <zh-button v-func:eduStudentEnrollPreOffline0002 link @click="showdetail(row, true)" style="color: green">查看</zh-button>
        <zh-button v-func:eduStudentEnrollPreOffline0005 link @click="showdetail(row, false)">修改</zh-button>
        <zh-button v-func:eduStudentEnrollPreOffline0006 link @click="deleteData(row)" style="color: red">删除</zh-button>
      </template>
    </zh-table>

    <zh-dialog style="width: 80%" :title="pageData.title" v-model="pageData.detailVisible">
      <eduStudentEnrollPreOfflineForm
          ref="menuRef"
          :disabled="pageData.editFlag"
          @canner="canner"
          @refreshTable="refreshTable"
          :studentEnrollPreId="pageData.selectRow.studentEnrollPreId"
      ></eduStudentEnrollPreOfflineForm>
      <template #footer>
				<span class="dialog-footer">
					<zh-button @click="pageData.detailVisible = false">关闭</zh-button>
					<zh-button
              type="primary"
              :loading="pageData.saveLoading"
              :disabled="pageData.saveLoading"
              v-model:btnLoding="pageData.saveLoading"
              @click="save"
          >
						保存
					</zh-button>
				</span>
      </template>
    </zh-dialog>
  </div>
</template>
<script lang="ts" setup name="eduStudentEnrollPreOfflineIndex">
import { ElMessageBox, ElMessage } from 'element-plus';
import eduStudentEnrollPreOfflineForm from './component/eduStudentEnrollPreOfflineForm.vue';

// ------------------接收传入参数(组件)-------------------

// ------------------钩子函数----------------------------
// 初始化
onMounted(() => {
  init();
});

// ------------------定义子组件--------------------------
const queryTable = ref();
const queryFormRef = ref();
const menuRef = ref();

const statusMap = {
  0: {
    status: 'error',
    text: '无效',
  },
  1: {
    status: 'processing',
    text: '有效',
  },
};

// ------------------变量区------------------------------
const pageData = reactive({
  advanced: false,

  tableColumns: [
    {
      type: 'seq',
      minWidth: 60,
      fixed: 'left',
      align: 'center',
      title: '序号',
    },
    {
      field: 'studentEnrollPreId',
      title: '主键',
      visible: false,
      align: 'center',
      minWidth: 80,
    },
    {
      field: 'batchNo',
      title: '批次号',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'personId',
      title: '学生人员id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'idcard',
      title: '学生身份证',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fullName',
      title: '学生',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'cardType',
      title: '学生证件类型',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'birthYmd',
      title: '出生日期',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'sex',
      title: '性别',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'age',
      title: '学生年龄',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'submitterId',
      title: '提交人员userId',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'submitterName',
      title: '提交人员姓名',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'orgId',
      title: '提交人员所属组织',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'telphone',
      title: '提交人员联系电话',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'remarks',
      title: '备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'address',
      title: '现居住地址',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'householdPlace',
      title: '户籍地',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fatherId',
      title: '父亲id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fatherName',
      title: '父亲姓名',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fatherCardType',
      title: '父亲（监护人）证件类型',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fatherIdcard',
      title: '父亲身份证',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fatherWork',
      title: '父亲工作',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fatherCellphone',
      title: '父亲手机',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'motherId',
      title: '母亲id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'motherName',
      title: '母亲姓名',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'motherCardType',
      title: '母亲证件类型',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'motherIdcard',
      title: '母亲身份证',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'motherWork',
      title: '母亲工作',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'motherCellphone',
      title: '母亲手机',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'enrollPreType',
      title: '预采集类型',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'schoolId',
      title: '学校',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'shortName',
      title: '学校简称',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'schoolCategory',
      title: '学段',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'type',
      title: '数据类型(insert,update)',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'year',
      title: '年份',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fileInfo',
      title: '材料信息',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'areaCode',
      title: '行政区划',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'houseSyncFlag',
      title: '房产同步状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'houseSyncRemark',
      title: '房产同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'householdSyncFlag',
      title: '户籍同步状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'householdSyncRemark',
      title: '户籍同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'netsignSyncFlag',
      title: '网签同步状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'netsignSyncRemark',
      title: '网签同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'cbSyncFlag',
      title: '参保同步状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'cbSyncRemark',
      title: '参保同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'qySyncFlag',
      title: '开办企业同步状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'qySyncRemark',
      title: '开办企业同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'jzzSyncFlag',
      title: '居住证同步状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'jzzSyncRemark',
      title: '居住证同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'beforeFlag',
      title: '预报名同步标识',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'beforeRemark',
      title: '预报名同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'busNo',
      title: '流水号',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'authStatus',
      title: '审核状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'authRemarks',
      title: '审核意见',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'authTime',
      title: '审核时间',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'authUserId',
      title: '审核人',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'familyFlag',
      title: '出生证比对状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'familyType',
      title: '家庭关系比对类型1 大数据比对 2 人工核对',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'familyRemark',
      title: '出生证比对备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'calculateFlag',
      title: '预测比对情况',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'calculateRemark',
      title: '预测同步备注',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'followingFlag',
      title: '是否非随迁子女 0 否 1 是',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'consistentFlag',
      title: '是否房户一致 0 未比对 1比对通过 2比对不通过',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'aborigineFlag',
      title: '是否原住民',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'consistentType',
      title: '房户一致比对类型：1 大数据比对 2 人工核对',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'consistentRemarks',
      title: '一致情况说明',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'consistentUserId',
      title: '房产一致人工操作人',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'consistentTime',
      title: '房产一致性处理时间',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'houseId',
      title: '房产id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'householdId',
      title: '户籍id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'serviceAreaFlag',
      title: '是否服务区 0 否 1是',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'agentEnrollFlag',
      title: '代理报名：0 否 1是，代理报名将不控制房产等所有人',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'operate',
      title: '操作',
      fixed: 'right',
      align: 'center',
      minWidth: 210,
      slots: {
        // 使用插槽模板渲染
        default: 'operate',
      },
    },
  ],
  queryParams: {} as any,
  dictData: {} as any,
  title: '',
  detailVisible: false,
  editFlag: false,
  selectRow: {} as any,
  saveLoading: false,
  showType: true,
  campusParam: {} as any,
});
// ------------------方法区------------------------------
const init = () => {
  getDict();
  refreshTable();
};
// 查询数据字典信息
const getDict = () => {
  const params = {} as any;
  params.dictFields = '';
  $api.common.getBatchDict.post(params).then((res) => {
    pageData.dictData = res.result;
  });
};

//使用子组件方法，关闭弹窗
const canner = (e: any) => {
  pageData.detailVisible = e;
};

const showAdd = () => {
  pageData.title = '新增';
  pageData.detailVisible = true;
  pageData.editFlag = false;
  pageData.selectRow = {};
};

const showdetail = (row, flag) => {
  if (!flag) {
    pageData.title = '信息修改';
  } else {
    pageData.title = '查看详情';
  }
  pageData.selectRow = row;
  pageData.editFlag = flag;
  pageData.detailVisible = true;
};
//保存
const save = () => {
  menuRef.value.saveBase();
};

//刷新
const refreshTable = () => {
  queryTable.value.refresh(pageData.queryParams);
};
//删除
const deleteData = (row) => {
  ElMessageBox.confirm('是否确认删除？').then(() => {
    let params = {} as any;
    params.studentEnrollPreId = row.studentEnrollPreId;
    $api.common.send.post('eduStudentEnrollPreOffline0006', params).then(() => {
      ElMessage.success('删除成功');
      refreshTable();
    });
  });
};

</script>
<style lang="scss" scoped></style>
